/*
 * Copyright (c) 2022.版权所有高金磊
 */

package 领扣算法.A简单题.到目标元素的最小距离;

public class Main {
    public int getMinDistance(int[] nums, int target, int start) {
        int min=Integer.MAX_VALUE;
        for (int i = 0; i < nums.length; i++) {
            if (target==nums[i]){
                if (Math.abs(start-i)>min)
                    return min;
                else
                {
                    min=Math.abs(start-i);
                }
            }
        }
        return min;
    }
}
